package cn.com.ai.ollama;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.util.HashMap;
import java.util.Map;

public class OpenWebUI {
    public static void main(String[] args) {
        Map<String, String> registerParams = new HashMap<String, String>();
        registerParams.put("name", "user2");
        registerParams.put("password", "user2");
        registerParams.put("email", "user2@qq.com");
        registerParams.put("role", "user");

        HttpResponse execute = HttpRequest.post("http://172.32.1.169:31425/api/v1/auths/add")
                .header("Content-Type", "application/json")
                .header("authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImFjNTM5NTJmLWM2MDgtNDAzNS1hODRkLTVlZjM5MDE1OGFlNSJ9.3IbTd3AdjW1gLJiDxxnS4xOfIjU3UaRjmFx3pZdrKz4")
                .body(JSONUtil.toJsonStr(registerParams))
                .execute();
        if (!execute.isOk()) {
            System.out.println("注册失败：" + execute.body());
        }
        JSONObject jsonResponse = JSONUtil.parseObj(execute.body());
        String token = jsonResponse.getStr("token");
        System.out.println("注册用户token:"+token);
    }
}
